package mapper;

import com.tomorrow.javabean.Role;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;

@Mapper
public interface RoleAnnotationMapper {
    //根据用户id查询角色信息
    @Select("select * from role r left join user_role ur on r.rid = ur.rid where ur.uid = #{uid}")
    @Results(id = "RoleResultMap", value = {
            @Result(column = "rid", property = "rid", id = true),
            @Result(column = "rid", property = "permissions",
                    many = @Many(select = "mapper.PermissionAnnotationMapper.selectPermissionByRid", fetchType = FetchType.LAZY)),
    })
    public Role findRoleByUid(@Param("uid") Integer uid);
}
